import pygame

# 初始化
pygame.init()
is_loop = True
# 设置屏幕大小
screen = pygame.display.set_mode((500, 700))
# 设置标题
pygame.display.set_caption('接小球游戏')
# 获取时钟
clock = pygame.time.Clock()
# 设置矩形区域
rect = pygame.Rect(200, 600, 100, 30)
point = [250,20]
life = 0
score = 0
# 设置字体
font = pygame.font.SysFont('SimHei', 24)
while is_loop:
    # 处理事件
    for e in pygame.event.get():
        if e.type == pygame.QUIT:
            is_loop = False
    # 屏幕填充为黑色
    screen.fill((0, 0, 0))
    # 画矩形
    pygame.draw.rect(screen, (0, 255, 0),rect)
    # 画圆
    pygame.draw.circle(screen, (255, 0, 0), point, 20)
    # 添加要渲染的文字
    score_text = font.render(f'命数{life}', True, (100, 200, 0))
    life_text = font.render(f'得分{score}',False, (100, 200, 100) )
    # 将图像添加主屏幕scrren上
    screen.blit(life_text, (430,0))
    # 更新
    screen.blit(score_text, (0,0))
    point[1] += 5
    # 设置每秒最多40帧
    clock.tick(40)
    # 更新
    pygame.display.update()

pygame.quit()
